# Maintainer: Peter van Dijk <peter.van.dijk@powerdns.com>
_pkgname=pdns-recursor # upstream package name
pkgname=pdns-recursor
pkgver=4.9.2
pkgrel=0
pkgdesc="PowerDNS Recursive Server"
url="https://www.powerdns.com/"
arch="all !s390x" # broken context
license="GPL-2.0-only WITH OpenSSL-Exception"
makedepends="autoconf automake libtool boost-dev openssl-dev>3 libsodium-dev lua5.3-dev
	net-snmp-dev curl curl-dev"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-openrc"
pkgusers="recursor"
pkggroups="recursor"
source="https://downloads.powerdns.com/releases/$_pkgname-${pkgver//_/-}.tar.bz2
	$_pkgname.initd
	recursor.conf
	"
builddir="$srcdir/$_pkgname-${pkgver//_/-}"

# secfixes:
#   4.8.1-r0:
#     - CVE-2023-22617
#   4.7.2-r0:
#     - CVE-2022-37428
#   4.6.1-r0:
#     - CVE-2022-27227
#   4.3.5-r0:
#     - CVE-2020-25829
#   4.3.2-r0:
#     - CVE-2020-14196
#   4.3.1-r0:
#     - CVE-2020-10995
#     - CVE-2020-12244
#   4.1.9-r0:
#     - CVE-2019-3806
#     - CVE-2019-3807
#   4.1.8-r0:
#     - CVE-2018-16855
#   4.1.7-r0:
#     - CVE-2018-10851
#     - CVE-2018-14644
#     - CVE-2018-14626
#   4.1.1-r0:
#     - CVE-2018-1000003
#   4.0.7-r0:
#     - CVE-2017-15090
#     - CVE-2017-15092
#     - CVE-2017-15093
#     - CVE-2017-15094

build() {
	./configure --prefix=/usr \
		--sysconfdir=/etc/pdns \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		--libdir=/usr/lib/pdns \
		--enable-dns-over-tls \
		--enable-unit-tests
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	mv "$pkgdir"/etc/pdns/recursor.conf-dist  "$pkgdir"/etc/pdns/recursor.conf
	cat "$srcdir/recursor.conf" >> "$pkgdir"/etc/pdns/recursor.conf

	install -m755 -D "$srcdir/$_pkgname.initd" \
		"$pkgdir/etc/init.d/$pkgname"

}

sha512sums="
ee2dac5d256c9f4a9155fe6885522c5413482f0fd179099e956db2abbf4510fc6696fc1ac93bb4af341ebb2f052350637524267aa21fe6a0e92194e9219d1d45  pdns-recursor-4.9.2.tar.bz2
71f7be51d3a9a78f22f3946e95534d4f5b37b3bcbd1891ad3a17095be545fdb0eaf239d58c9f40ccc642542150c0b35ed025bf69acabfa779c0ab10c67a5e796  pdns-recursor.initd
abda278d29b21e9635fb154c8685e5d346f47889498f075a8dd2e486f8ea4dcc2ccd20f4245783e4d55534fed88c49825b22fd3d1c55d8645522ce45cc53d661  recursor.conf
"
